package net.newsmth.smthapp.android.widget;

import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;

import net.newsmth.smthapp.android.R;
import net.newsmth.smthapp.android.ui.LoginActivity;


/**
 * Created by Hatsune Miku on 3/31/14.
 */
public class ErrorMessageTextView extends TextView implements ErrorView {
    public ErrorMessageTextView(Context context) {
        super(context);
        initStyle();
    }

    public ErrorMessageTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initStyle();
    }

    public ErrorMessageTextView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        initStyle();
    }

    private void initStyle() {
        this.setTextColor(getResources().getColor(R.color.main_error_text));
    }

    public void showMessage(String message) {
        this.setVisibility(VISIBLE);
    }

    public void reset() {
        this.setVisibility(View.GONE);
    }


    @Override
    public void showGeneralErrorMessage(String message) {

    }

    @Override
    public void hideGeneralErrorMessage() {

    }

    @Override
    public void redirectToLogin() {
        Intent intent = new Intent(getContext(), LoginActivity.class);
        intent.putExtra(LoginActivity.IS_AUTO_FINISH_KEY, true);
        getContext().startActivity(intent);
    }
}
